//
//  CLDrawViewController.m
//  CareLink
//
//  Created by apple on 16/8/18.
//  Copyright © 2016年 Seven Team. All rights reserved.
//

#import "CLDrawViewController.h"
#import "CLHomeViewController.h"
#import "CLLeftDrawerTableViewController.h"
#import "SideWayTableController.h"
#import "CLNavgationController.h"
@interface CLDrawViewController ()

@end

@implementation CLDrawViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // 主界面
    CLHomeViewController *homeViewController = [[CLHomeViewController alloc]init];
    CLNavgationController *navigationController = [[CLNavgationController alloc]initWithRootViewController:homeViewController];
    // 左侧侧滑登录界面
    SideWayTableController *leftVc =  [[SideWayTableController alloc]init];
    //设置全局数据
    [[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:@"isLoad"];

//    leftVc.view.backgroundColor = [UIColor yellowColor];

    // 设置抽屉控制器controller
     MMDrawerController *drawController =[self initWithCenterViewController:navigationController leftDrawerViewController:leftVc];
//    // 设置抽屉控制器效果
    [drawController setShowsShadow:YES];
    [drawController setRestorationIdentifier:@"MMDrawer"];
    [drawController setMaximumLeftDrawerWidth:270.0];
    [drawController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
    [drawController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];


    [drawController setGestureShouldRecognizeTouchBlock:^BOOL(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) {
        BOOL shouldRecognizeTouch = NO;
        if(drawerController.openSide == MMDrawerSideNone && [gesture isKindOfClass:[UIPanGestureRecognizer class]]){
            CLNavgationController *nav = (CLNavgationController *)drawerController.centerViewController;
            //判断哪个控制器可以滑到抽屉
            if([nav.topViewController isKindOfClass:[CLHomeViewController class]]){
                shouldRecognizeTouch = YES;
            }else{
                //返回yes表示可以滑动到左右侧抽屉
                shouldRecognizeTouch = NO;
            }
        }
        return shouldRecognizeTouch;
    }];

    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];


    

}



@end
